home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / DBL Pascal Library / DefProcs / SICN Cntl / SICN Test.p < prev    next >
Text File  |  1992-03-02  |  2KB  |  96 lines

  1. program IconTest;
  2.  
  3.     const
  4.         dialogID = 128;
  5.         firstIconButton = 2;
  6.         upDnIconButton = 3;
  7.         lastIconButton = 4;
  8.         disableCheckbox = 5;
  9.         hideCheckbox = 6;
  10.         reportText = 7;
  11.  
  12.     var
  13.         theDialog: DialogPtr;
  14.         itemHit: Integer;
  15.         i: Integer;
  16.         evt: EventRecord;
  17.  
  18.     function GetControlHandle (item: Integer): ControlHandle;
  19.         var
  20.             kind: Integer;
  21.             h: Handle;
  22.             r: Rect;
  23.     begin
  24.         GetDItem(theDialog, item, kind, h, r);
  25.         if BAND(kind, $FC) = ctrlItem then
  26.             GetControlHandle := ControlHandle(h)
  27.         else
  28.             GetControlHandle := nil;
  29.     end;
  30.  
  31.     procedure ReportValue (item: Integer);
  32.         var
  33.             value: Integer;
  34.             theString: Str255;
  35.             kind: Integer;
  36.             h: Handle;
  37.             r: Rect;
  38.     begin
  39.         value := GetCtlValue(GetControlHandle(item));
  40.         NumToString(value, theString);
  41.         GetDItem(theDialog, reportText, kind, h, r);
  42.         SetIText(h, theString);
  43.     end;
  44.  
  45. begin
  46.     theDialog := GetNewDialog(dialogID, nil, POINTER(-1));
  47.     SetPort(theDialog);
  48.     TextFont(geneva);    {Try different fonts and sizes to see how useWFont variant works…}
  49.     TextSize(9);
  50.     ShowWindow(theDialog);
  51.     for i := 1 to 3 do    {Have to do this to synchronize TE items to the window font!}
  52.         if EventAvail(everyEvent, evt) then
  53.             ;
  54.     with DialogPeek(theDialog)^.textH^^ do
  55.         begin
  56.             txFont := theDialog^.txFont;
  57.             txSize := theDialog^.txSize;
  58.         end;
  59.     InitCursor;
  60.     repeat
  61.         ModalDialog(nil, itemHit);
  62.  
  63.         if itemHit = firstIconButton then
  64.             case GetCtlValue(GetControlHandle(firstIconButton)) of
  65.                 0, 1: 
  66.                     ;
  67.                 otherwise
  68.                     SysBeep(5);
  69.             end;
  70.  
  71.         if itemHit = upDnIconButton then
  72.             SysBeep(1);
  73.  
  74.         if itemHit = disableCheckbox then
  75.             begin
  76.                 SetCtlValue(GetControlHandle(disableCheckbox), 1 - GetCtlValue(GetControlHandle(disableCheckbox)));
  77.                 if GetCtlValue(GetControlHandle(disableCheckbox)) = 0 then
  78.                     HiliteControl(GetControlHandle(lastIconButton), 0)
  79.                 else
  80.                     HiliteControl(GetControlHandle(lastIconButton), 255);
  81.             end;
  82.  
  83.         if itemHit = hideCheckbox then
  84.             begin
  85.                 SetCtlValue(GetControlHandle(hideCheckbox), 1 - GetCtlValue(GetControlHandle(hideCheckbox)));
  86.                 if GetCtlValue(GetControlHandle(hideCheckbox)) = 0 then
  87.                     ShowControl(GetControlHandle(lastIconButton))
  88.                 else
  89.                     HideControl(GetControlHandle(lastIconButton));
  90.             end;
  91.  
  92.         ReportValue(itemHit);
  93.  
  94.     until itemHit = OK;
  95.     DisposDialog(theDialog);
  96. end.